package org.br.plotter.parser.math;

public class Complex {
	private double real;
	private double image;
	public Complex(double real, double image) {
		this.real = real;
		this.image = image;		
	}
	
	public Complex times(Complex cplx) {
		double multipliedReal = cplx.real;
		double multipliedImage = cplx.image;
		double multiReal = multipliedReal*real - multipliedImage*image;
		double multiImage = real*multipliedImage + multipliedReal*image;
		return new Complex(multiReal,multiImage);
	}
	
	public Complex times(double multipliedReal) {
		double multiReal = multipliedReal*real;
		double multiImage =  multipliedReal*image;
		return new Complex(multiReal,multiImage);
	}
	
	public Complex plus(Complex cplx) {
		double plusedreal = cplx.real;
		double plusedimage = cplx.image;
		return new Complex(plusedreal+real,plusedimage+image);
	}
	public Complex minus(Complex cplx) {
		double plusedreal = cplx.real;
		double plusedimage = cplx.image;
		return new Complex(real-plusedreal,image-plusedimage);
	}
	public Complex conjugate() {
		return new Complex(real,-image);
	}
	public double getReal() {
		return real;
	}
	
	public double getImage() {
		return image;
	}

}
